package com.hxk.ioText.charIo.nodeIo;

import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;

public class StringIo {

	public static void main(String[] args) {
		StringReader sr = null;
		StringWriter sw = null;
		try {
			sw = new StringWriter();
			sw.write("java 字符串流");
			sr = new StringReader(sw.getBuffer().toString());
			char[] cbuf = new char[1024];
			int len = sr.read(cbuf);
			System.out.println(new String(cbuf, 0, len));
		}catch (IOException e) {
			e.printStackTrace();
		}finally {
			if(sr != null) {
				sr.close();
			}
			try {
				if(sw != null) {
					sw.close();
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}

}
